<?php
/**
 * Created by PhpStorm.
 * User: win7
 * Date: 2018/12/20
 * Time: 21:01
 */
require  'config.php';
switch (@$_GET['a']){
    case 'xiu':
        if (!empty($_POST['oldpassword']) && !empty($_POST['newpassword']) && !empty($_POST['ode'])){
            $oldpassword = $_POST['oldpassword'];
            $newpassword = $_POST['newpassword'];
            $ode = $_POST['ode'];
            $name = $_POST['uname'];
            if ($ode == $_COOKIE['code1']){
                if ($oldpassword == $newpassword ){
                    $sql = "update user set password = '$oldpassword' where userName = '$name' ";
                    mysqli_query($link,$sql);
                    if (mysqli_affected_rows($link)>0){
                        echo "<script> 
                    alert('恭喜修改成功');
                    window.location.href = '../index.php';
                     </script>";
                    }else{
                        echo "<script> 
                    alert('两次密码输出不正确');
                    window.location.href = 'yanzheng.php';
                     </script>";
                    }

                }else{
                    echo "<script> 
                    alert('验证码有误');
                    window.location.href = 'yanzheng.php';
                     </script>";
                }
            }

        }else{
            echo "<script> 
                    alert('修改失败');
                    window.location.href = 'yanzheng.php';
                     </script>";
        }
        break;
}